//-----------------------------------------------------------------------------
//  File          : keycmd
//  Module        :
//  Description   : Header file for keycmd.c
//  Author        : Lewis
//  Notes         :
//
// ============================================================================
// | Naming conventions                                                       |
// | ~~~~~~~~~~~~~~~~~~                                                       |
// |        Struct define : Leading T                                         |
// |         Struct/Array : Leading s                                         |
// |             Constant : Leading K                                         |
// |      Global Variable : Leading g  (variable use outside one C file)      |
// |                                                                          |
// |   BYTE( 8 Bits) size : Leading b                                         |
// |   CHAR( 8 Bits) size : Leading c                                         |
// |   WORD(16 Bits) size : Leading w                                         |
// |  DWORD(32 Bits) size : Leading d                                         |
// |    int(32 Bits) size : Leading i                                         |
// | DDWORD(64 Bits) size : Leading dd                                        |
// |              Pointer : Leading p                                         |
// |                                                                          |
// |    Function argument : Leading a                                         |
// |       Local Variable : All lower case                                    |
// |                                                                          |
// | Examples:                                                                |
// |                Array : Leading s, (sb = arrary of byte, etc)             |
// |              Pointer : Leading p, (pb = pointer of byte, etc)            |
// ============================================================================
//
//  Date          Who         Action
//  ------------  ----------- -------------------------------------------------
//  20 Oct  2008  Lewis       Port form CREON KEYDLL.
//-----------------------------------------------------------------------------
#ifndef _INC_KEYCMD_H_
#define _INC_KEYCMD_H_
#include "common.h"

//-----------------------------------------------------------------------------
//     Defines
//-----------------------------------------------------------------------------
//// Key usage
//#define USE_LEFT                0x40
//#define USE_RIGHT               0x80
//#define USE_THIRD               0xC0

// Move to Key2dll.h
////KVC mode
//#define KVC_EXIST               0x01
//
////RESPONSE CODE
//#define RESP_OK                 0
//#define RESP_KEY_CLR            1
//#define RESP_KBD_FAILED         1
//#define RESP_INVALID_TID        1
//#define RESP_OUT_OF_SEQ         1
//#define RESP_TMK_NOT_LOAD       1
//#define RESP_KVC_ERR            1
//#define RESP_WRONG_KEY_FUNC     1
//#define RESP_FONT_TBL_FULL      1
//#define RESP_LOCATION_ERROR     1
//#define RESP_SINGLE_KEY_ONLY    2
//#define RESP_EPROM_KEY_FAILED   2
//#define RESP_PARITY_ERROR       2
//#define RESP_LCD_ERROR          2
//#define RESP_KEY_CANCEL         2
//#define RESP_LENGTH_ERROR       2
//#define RESP_KEY_EXIST          2
//#define RESP_TIMEOUT            3
//#define RESP_KEY_INDEX_ERROR    4
//#define RESP_MODE_ERROR         5
//#define RESP_AUTH_ERROR         6
//#define RESP_DATA_LEN_ERR       7

////Encryption/Decryption mode
//#define MODE_ECB                0
//#define MODE_CBC                1

//-----------------------------------------------------------------------------
//     Functions
//-----------------------------------------------------------------------------
extern WORD KeyInject(BYTE *aKeyStr);
extern WORD KeyEncrypt(BYTE aKeyidx, BYTE *aDataBuf, WORD aDataLen);
extern WORD KeyDecrypt(BYTE aKeyidx, BYTE *aDataBuf, WORD aDataLen);
extern WORD KeyTriEncrypt(BYTE aKeyidx, BYTE *aDataBuf, WORD aDataLen);
extern WORD KeyTriDecrypt(BYTE aKeyidx, BYTE *aDataBuf, WORD aDataLen);
extern WORD GetPinX98(BYTE *aPINBlock, BYTE *aPromptMsg, BYTE aKeyIdx);
extern WORD X99CalMac(BYTE *aMacPtr, BYTE *aDataPtr, DWORD aLen);
extern void SetOpMode(BYTE aMode, BYTE *aInitData);
extern void GetOpMode(BYTE *aMode);
extern WORD KeyCalMac(BYTE aKeyIdx, BYTE *aDataBuf, WORD aDataLen);
#endif // _INC_KEYCMD_H_
